package com.esri.core.geometry;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class Envelope3D {
    public double xmax;
    public double xmin;
    public double ymax;
    public double ymin;
    public double zmax;
    public double zmin;

    public static Envelope3D construct(double d, double d2, double d3, double d4, double d5, double d6) {
        Envelope3D envelope3D = new Envelope3D();
        envelope3D.xmin = d;
        envelope3D.ymin = d2;
        envelope3D.zmin = d3;
        envelope3D.xmax = d4;
        envelope3D.ymax = d5;
        envelope3D.zmax = d6;
        return envelope3D;
    }

    public void setInfinite() {
        this.xmin = NumberUtils.negativeInf();
        this.xmax = NumberUtils.positiveInf();
        this.ymin = NumberUtils.negativeInf();
        this.ymax = NumberUtils.positiveInf();
        this.zmin = NumberUtils.negativeInf();
        this.zmax = NumberUtils.positiveInf();
    }

    public void setEmpty() {
        this.xmin = NumberUtils.NaN();
        this.zmin = NumberUtils.NaN();
    }

    public boolean isEmpty() {
        return NumberUtils.isNaN(this.xmin);
    }

    public boolean isValid() {
        return (NumberUtils.isNaN(this.xmin) || NumberUtils.isNaN(this.xmax) || NumberUtils.isNaN(this.ymin) || NumberUtils.isNaN(this.ymax) || this.xmin > this.xmax || this.ymin > this.ymax) ? false : true;
    }

    public void setEmptyZ() {
        this.zmin = NumberUtils.NaN();
    }

    public boolean isEmptyZ() {
        return NumberUtils.isNaN(this.zmin);
    }

    public boolean isValidZ() {
        return (NumberUtils.isNaN(this.zmin) || NumberUtils.isNaN(this.zmax) || this.zmin > this.zmax) ? false : true;
    }

    public boolean hasEmptyDimension() {
        return isEmpty() || isEmptyZ();
    }

    public void setCoords(double d, double d2, double d3, double d4, double d5, double d6) {
        this.xmin = d;
        this.ymin = d2;
        this.zmin = d3;
        this.xmax = d4;
        this.ymax = d5;
        this.zmax = d6;
    }

    public void setCoords(double d, double d2, double d3) {
        this.xmin = d;
        this.ymin = d2;
        this.zmin = d3;
        this.xmax = d;
        this.ymax = d2;
        this.zmax = d3;
    }

    public void setCoords(Point3D point3D, double d, double d2, double d3) {
        double d4 = point3D.x - (d * 0.5d);
        this.xmin = d4;
        this.xmax = d4 + d;
        double d5 = point3D.y - (d2 * 0.5d);
        this.ymin = d5;
        this.ymax = d5 + d2;
        double d6 = point3D.z - (0.5d * d3);
        this.zmin = d6;
        this.zmax = d6 + d3;
    }

    public void move(Point3D point3D) {
        this.xmin += point3D.x;
        this.ymin += point3D.y;
        this.zmin += point3D.z;
        this.xmax += point3D.x;
        this.ymax += point3D.y;
        this.zmax += point3D.z;
    }

    public void copyTo(Envelope2D envelope2D) {
        envelope2D.xmin = this.xmin;
        envelope2D.ymin = this.ymin;
        envelope2D.xmax = this.xmax;
        envelope2D.ymax = this.ymax;
    }

    public void mergeNE(double d, double d2, double d3) {
        if (this.xmin > d) {
            this.xmin = d;
        } else if (this.xmax < d) {
            this.xmax = d;
        }
        if (this.ymin > d2) {
            this.ymin = d2;
        } else if (this.ymax < d2) {
            this.ymax = d2;
        }
        if (this.zmin != NumberUtils.NaN()) {
            if (this.zmin > d3) {
                this.zmin = d3;
                return;
            } else if (this.zmax < d3) {
                this.zmax = d3;
                return;
            } else {
                return;
            }
        }
        this.zmin = d3;
        this.zmax = d3;
    }

    public void merge(double d, double d2, double d3) {
        if (isEmpty()) {
            this.xmin = d;
            this.ymin = d2;
            this.zmin = d3;
            this.xmax = d;
            this.ymax = d2;
            this.zmax = d3;
            return;
        }
        mergeNE(d, d2, d3);
    }

    public void merge(Point3D point3D) {
        merge(point3D.x, point3D.y, point3D.z);
    }

    public void merge(Envelope3D envelope3D) {
        if (envelope3D.isEmpty()) {
            return;
        }
        merge(envelope3D.xmin, envelope3D.ymin, envelope3D.zmin);
        merge(envelope3D.xmax, envelope3D.ymax, envelope3D.zmax);
    }

    public void merge(double d, double d2, double d3, double d4, double d5, double d6) {
        merge(d, d2, d3);
        merge(d4, d5, d6);
    }

    public void construct(Envelope1D envelope1D, Envelope1D envelope1D2, Envelope1D envelope1D3) {
        if (envelope1D.isEmpty() || envelope1D2.isEmpty()) {
            setEmpty();
            return;
        }
        this.xmin = envelope1D.vmin;
        this.xmax = envelope1D.vmax;
        this.ymin = envelope1D2.vmin;
        this.ymax = envelope1D2.vmax;
        this.zmin = envelope1D3.vmin;
        this.zmax = envelope1D3.vmax;
    }

    public void queryCorners(Point3D[] point3DArr) {
        if (point3DArr == null || point3DArr.length < 8) {
            throw new IllegalArgumentException();
        }
        point3DArr[0] = new Point3D(this.xmin, this.ymin, this.zmin);
        point3DArr[1] = new Point3D(this.xmin, this.ymax, this.zmin);
        point3DArr[2] = new Point3D(this.xmax, this.ymax, this.zmin);
        point3DArr[3] = new Point3D(this.xmax, this.ymin, this.zmin);
        point3DArr[4] = new Point3D(this.xmin, this.ymin, this.zmax);
        point3DArr[5] = new Point3D(this.xmin, this.ymax, this.zmax);
        point3DArr[6] = new Point3D(this.xmax, this.ymax, this.zmax);
        point3DArr[7] = new Point3D(this.xmax, this.ymin, this.zmax);
    }

    public void setFromPoints(Point3D[] point3DArr) {
        if (point3DArr == null || point3DArr.length == 0) {
            setEmpty();
            return;
        }
        Point3D point3D = point3DArr[0];
        setCoords(point3D.x, point3D.y, point3D.z);
        for (int i = 1; i < point3DArr.length; i++) {
            Point3D point3D2 = point3DArr[i];
            mergeNE(point3D2.x, point3D2.y, point3D2.z);
        }
    }
}
